
import numpy as np


#   多维数组运算

# A = np.array([1,2,3,4,5])
# B = np.array([[1,2,3,4],[5,6,7,8]])
# C = np.array([[1,2,3],[4,5,6],[7,8,9]])
#
# print(A)
#
# print(np.ndim(A))  # np.ndim()  用来获取当前数组的维度
# print(np.ndim(B))
# print(np.ndim(C))
#
# print(A.shape)     # 一维数组的 shape 表示该一维数组的元素个数
# print(B.shape)     #  二维数组的 shape 表示该二维数组的行列
# print(C.shape)     #  shape 的返回值时一个元组，可以通过下标来访问

# 矩阵的乘法运算

A = np.array([[1,2],[3,4]])
print(A.shape)
B = np.array([[5,6],[7,8]])
print(B.shape)
C = np.array([[1,2],[3,4],[5,6]])
print(C.shape)
D = np.array([1,2,3])
print(D.shape)

print(f"np.dot(A,B)=\n{np.dot(A,B)}")
print(f"np.dot(C,A)=\n{np.dot(C,A)}")
print(f"np.dot(C,B)=\n{np.dot(C,B)}")
print(f"np.dot(D,A)=\n{np.dot(D,C)}")

